package com.smartwebx.ha.dal.usebean;

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;

import com.google.common.base.Objects;
import com.smartwebx.ha.dal.usebean.abstr.AbstractStrId;

public class StationAdminArea implements Serializable, AbstractStrId {
	private static final long serialVersionUID = 1L;
	
	private int statId;
	private String id;// 行政区域id
	private String parentId;// 上级区域id
	private String name;
	private int childs;// 所属有多少站
	private int level;// 区域等级
	private char statType;// 站的类型，0 行政站类；1 水雨情站类
	private boolean checked;

	public StationAdminArea() {

	}

	public StationAdminArea(String id, String parentId, String name, int level) {
		this.childs = 0;
		this.statType = '0';

		this.id = id;
		this.parentId = parentId;
		this.name = name;
		this.level = level;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = StringUtils.trim(id);
	}
	
	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = StringUtils.trim(parentId);
	}

	public String getName() {
		String oname = null;
		if (statType == '1') {// 水雨情站
			oname = this.name + "(" + this.id + ")";
		} else {
			oname = name;
		}
		return oname;
	}

	public void setName(String name) {
		this.name = StringUtils.trim(name);
	}

	public int getChilds() {
		return childs;
	}

	public void setChilds(int childs) {
		this.childs = childs;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public char getStatType() {
		return statType;
	}

	public void setStatType(char statType) {
		this.statType = statType;
	}

	public boolean getChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	
	public int getStatId() {
		return statId;
	}

	public void setStatId(int statId) {
		this.statId = statId;
	}

	@Override
	public int hashCode() {
		return Objects.hashCode(id, parentId, name, childs, level, statType,
				checked);
	}

	@Override
	public boolean equals(Object object) {
		if (object instanceof StationAdminArea) {
			StationAdminArea that = (StationAdminArea) object;
			return Objects.equal(this.id, that.id)
					&& Objects.equal(this.parentId, that.parentId)
					&& Objects.equal(this.name, that.name)
					&& Objects.equal(this.childs, that.childs)
					&& Objects.equal(this.level, that.level)
					&& Objects.equal(this.statType, that.statType)
					&& Objects.equal(this.checked, that.checked);
		}
		return false;
	}

	@Override
	public String toString() {
		return Objects.toStringHelper(this).add("id", id)
				.add("parentId", parentId).add("name", name)
				.add("childs", childs).add("level", level)
				.add("statType", statType).add("checked", checked).toString();
	}

}
